﻿using System.Diagnostics;
using pub.CmdUI.Cmd;
using pub.CmdUI.UI.Control;

namespace todo.Cmd.Tool
{
    public class SchedulerCmd : DefaultCmd, ICmdState
    {
        private string filePath;

        public SchedulerCmd()
        {
            filePath = App.Path + @"\scheduler.exe";
        }

        bool ICmdState.Enabled
        {
            get { return System.IO.File.Exists(filePath); }
        }

        public override void Execute(IControlUI controlUi)
        {
            var args = "/show";

            var todoListFile = App.TodoListFile;
            if (todoListFile != App.TempNewFile)
            {
                args += " /add \"" + todoListFile + '"';
            }
            Process.Start(filePath, args);
        }
    }
}